Recent years have seen a wide spread of moving image capturing devices, still image capturing devices, and moving and still image capturing devices, such as digital video cameras, digital still cameras, camera-equipped mobile phones, surveillance cameras, and on-vehicle cameras.
In these devices having the imaging function, the memory of a recording medium which has limited storage capacity generally becomes full in a short time when data of captured images are directly recorded on the recording medium. Moreover, in the case of directly transmitting data of captured images by way of a transmission path through which data of limited size can be transmitted, it is not possible to transmit the data of captured images in real time. It is therefore common to compress data of captured images in various schemes and then perform other processing on the data reduced in amount when other processing is supposed to be performed on the data.
For example, when the data of captured images are data of moving images, an inter-frame coding scheme is adopted as a compression means. The inter-frame coding scheme is a scheme which is based on the fact that the correlation between one frame and another is strong in video signals.
Among proposed variations of this inter-frame coding scheme, a frequently used one is a transform coding scheme in which a difference between frames in video signals is calculated, and on a difference signal indicating the calculated difference, the orthogonal transform which efficiently uses image correlation within the two-dimensional space is then performed. In particular, a coding scheme based on, as the orthogonal transform, the discrete cosine transform (DCT) has been adopted as a coding scheme of international standards such as ISO/IEC 11172-2 (commonly known as MPEG-1) that is a moving picture coding standard for storage media.
In the inter-frame coding scheme, when a current frame is an inter-frame coded frame, a difference between frames in video signals is calculated, and a value of this difference is transformed into variable-length codes such as Huffman codes.
It is essential that a bit stream (a sequence of compressed codes) generated by performing a coding process on a video stream (image data) can be decoded. It is already known that the decoding process of a bit stream needs to be performed per frame in synchronization with a corresponding video stream and therefore requires a video buffer.
In other words, it is essential that the code amount is controlled (i.e., the rate control is performed) in the coding process so as to avoid overflow and underflow of the video buffer of an assumed device which performs predetermined decoding. For example, as a method of controlling the code amount, a method of a quantization step determination type is used in which an amount of codes being generated is monitored to determine a quantization parameter to be used for coding.
However, even with such per-picture control on a quantization parameter as to avoid overflow and underflow of a video buffer, there is a problem of a failure to prevent overflow of the code amount, for example, for an image which includes fine patterns or a scene with drastic motion such as a scene change.
In this case, the stream following the picture at which the overflow of the code amount occurs cannot be decoded by the assumed decoding device, which means that another control on a quantization parameter and another coding process are required to generate a bit stream which causes no overflow nor underflow of a video buffer in a decoding process.
Re-coding methods have been proposed such as a method of two-pass coding or a method in which coding is stopped at the time of detection of overflow or underflow of a video buffer and then resumes from a point a predetermined period of time ahead of the time of detection (see Patent Literature 1).